package com.hst.capacity.infra.persistence.jpa.setting.price;

import com.hst.capacity.domain.model.entity.order.intercity.IntercityOrderEntity;
import com.hst.capacity.domain.model.entity.setting.price.SpPremiumPriceEntity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface SpPremiumPriceRepository extends JpaRepository<SpPremiumPriceEntity, String> {

    @Query("select t from SpPremiumPriceEntity t where t.idPrice=:idPrice")
    List<SpPremiumPriceEntity> findByIdPriceAll(@Param("idPrice") String idPrice);

    @Query("select t from SpPremiumPriceEntity t where t.idPrice=:idPrice and t.status=:status")
    List<SpPremiumPriceEntity> findByIdPrice(@Param("idPrice") String idPrice, @Param("status") int status);

    @Query("select t from SpPremiumPriceEntity t where t.idFranchisee=:idFranchisee and (t.idPrice is null or t.idPrice='') order by t.idPremiumPrice")
    Page<SpPremiumPriceEntity> findByIdFranchiseeAll(@Param("idFranchisee") String idFranchisee, Pageable pageable);

    @Query("select t from SpPremiumPriceEntity t where t.idFranchisee=:idFranchisee and t.status=:status and (t.idPrice is null or t.idPrice='')")
    List<SpPremiumPriceEntity> findByIdFranchisee(@Param("idFranchisee") String idFranchisee, @Param("status") int status);

    SpPremiumPriceEntity findByIdPremiumPrice(String idPremiumPrice);

}
